<?php
	session_start();
	require_once('Pages/FrontPage.php');
	require_once('Database/Database.php');
	require_once('Database/Config.php');
	require_once('Login/LoginController.php');
	require_once('Login/LoginModel.php');
	require_once('Registration/RegistrationController.php');
	require_once('User/UserController.php');
	require_once('Gallery/GalleryController.php');
	require_once('Navigation/SwitchPage.php');
	require_once('Navigation/MainMenu.php');
	
	$front_html = new FrontPage();
	$page_switch = new SwitchPage();
	$main_menu = new MainMenu();
	$db = new Database();
	$config = new Config();
	$login_con = new LoginController();
	$login_model = new LoginModel($db);
	$reg_con = new RegistrationController();
	$user_con = new UserController();
	$gallery_con = new GalleryController();		
	// Anslutning till databasen.
	$db->Connect($config);
	
	$show_login = $login_con->DoControl($db);
	$show_user = $user_con->DoControl($db);
	$show_reg = $reg_con->DoControl($db);
	$show_gallery = $gallery_con->DoControl($db);
	$show_menu = $main_menu->ShowMainMenu();
	//
	if($login_model->IsLoggedIn() == true){
		$display = $front_html->DoHTML($show_login, $show_menu, $show_user);
		//
		if($page_switch->IsURLGallery() == true){
			$display = $front_html->DoHTML($show_login, $show_menu, $show_gallery);
		}
	}			
	else{
		$display = $front_html->DoHTML($show_login, $show_menu, $show_reg);
	}	
	echo $display;
	// Avstängning av anslutning till databasen.
	$db->Close();
?>